package com.tdp.neo4j;

import java.util.Set;

import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.conversion.Result;
import org.springframework.data.neo4j.repository.GraphRepository;

public interface AuthorsRepository extends GraphRepository<Authors>{
		
		@Query("match (n:Authors) return id(n)")
		Set<Long> findAllAuthors();
		
		Authors findByAuthorID(int id);
		Authors findByid(Long id);
		
//		@Query("match (m:Authors)-[r:COOP]->(n:Authors )  where id(m)={0} and id(n)={1} "
//				+ "return r")
		@Query("start m=node({0}),n=node({1}) match (m:Authors)-[r:COOP]->(n:Authors )  return r")
		Cooperations findRelationsBewteenTwoAuthorsThroughID(Long id1,Long id2);
		@Query("match (m:Authors)-[r:COOP]->(n:Authors )  where m.authorID={0} and n.authorID={1} "
				+ "return r")
		Cooperations findRelationsBewteenTwoAuthorsThroughAuthorID(int id1,int id2);
		
		@Query("match (m: Authors)-[r:COOP]->(n:Authors) where id(m)={0} return id(n)")
		Set<Long> findOutNeighbors(Long id);
		
		@Query("match (m: Authors )<-[r:COOP]-(n:Authors) where id(m)={0} return n")
		Set<Authors> findInNeighbors(Long id);
		
		
		
		
}
